package com.sikaryofficial.system.api;

import com.sikaryofficial.common.core.constant.ServiceNameConstants;
import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.domain.SysFile;
import com.sikaryofficial.system.api.factory.RemoteFileFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件服务
 *
 * @author qinjinyuan
 */
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService {
    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 视频上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/video/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<SysFile> uploadVideo(@RequestPart(value = "file") MultipartFile file);
    /**
     * 音视频合成
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/video/audioMerge", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<SysFile> mergeAudioAndVideo(@RequestPart(value = "file") MultipartFile file,
                                  @RequestParam(value = "audioPath", required = false) String audioPath,
                                  @RequestParam(value = "audioStartTime", defaultValue = "0", required = false) String audioStartTime,
                                  @RequestParam(value = "audioDuration", defaultValue = "0", required = false) String audioDuration,
                                  @RequestParam(value = "videoCoverUrl", required = false) String videoCoverUrl
    );
    /**
     * 音频上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/audio/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<SysFile> uploadAudio(@RequestPart(value = "file") MultipartFile file);
}
